package com.csust.automaticteach.app.student.learnchat;

import com.csust.automaticteach.app.rag.service.RAGService;
import com.csust.automaticteach.app.rag.service.impl.RAGService4VectorStore;
import com.csust.automaticteach.exception.BusinessException;
import com.csust.automaticteach.exception.ErrorCode;
import com.csust.automaticteach.model.entity.User;
import com.csust.automaticteach.model.enums.ChatSchemaEnum;
import org.springframework.stereotype.Component;
import reactor.core.publisher.Flux;

import static com.csust.automaticteach.model.enums.ChatSchemaEnum.DEEP_THINKING;
import static com.csust.automaticteach.model.enums.ChatSchemaEnum.CHAT_LEARN;
/**
 * @ ClassName LearnChatAppFacade
 * @ Description   学习助手门面类
 * @ Author 钰玟
 * @ Date 2025/9/28 下午4:02
 * Version 1.0
 **/
@Component
public class LearnChatAppFacade {
    private final OnlineLearnApp onlineLearnApp;
    private final RAGService ragService4VectorStore;

    public LearnChatAppFacade(OnlineLearnApp onlineLearnApp, RAGService4VectorStore ragService4VectorStore) {
        this.onlineLearnApp = onlineLearnApp;
        this.ragService4VectorStore = ragService4VectorStore;
    }

    /**
     * 聊天
     * @param message 输入
     * @param model 模型
     * @param learnChatId 对话id
     * @param promptId 提示id
     * @param chatSchema 聊天模式
     * @return Flux<String>
     */
    public Flux<String> chatToLearn(String message, String model, Long learnChatId, String promptId, ChatSchemaEnum chatSchema){
        return switch (chatSchema) {
            case CHAT_LEARN -> onlineLearnApp.ChatToLearn(message, model, learnChatId, promptId);
            case DEEP_THINKING -> onlineLearnApp.DeepThinkingChatToLearn(message, model, learnChatId, promptId);
            default -> throw new BusinessException(ErrorCode.PARAMS_ERROR, "不支持的聊天模式:" + CHAT_LEARN);
        };
    }


}
